package day02

object ScalaWordCount {
  def main(args: Array[String]): Unit = {
    val list = List("hello world hello tod","hello java hello scala hello world","hello java hello tod","hello c#");
    //对列表进行压扁操作，按照空格拆分，按照每个单词封装成元组，按照分组统计相同单词的列表个数，转换成List排序和取反
    val result = list.flatMap(_.split(" ")).map((_,1)).groupBy(_._1).mapValues(_.size).toList.sortBy(_._2).reverse
    println(result)
  }
}
